package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface SetMealMapper {
    @AutoFill(OperationType.INSERT)
    void insert(Setmeal setmeal);

    Page<SetmealVO> page(SetmealPageQueryDTO setmealPageQueryDTO);

    @Delete("delete from setmeal where id = #{id}")
    void delete(Long id);

    @Select("select * from setmeal where id = #{id};")
    Setmeal getById(Long id);


    //@Select("select s.* from setmeal s left join setmeal_dish sd on s.id = sd.setmeal_id where sd.dish_id = #{id}")

    @AutoFill(OperationType.UPDATE)
    void update(Setmeal setmeal);

    @Select("select * from setmeal where category_id = #{id}")
    List<Setmeal> getSetmealByCategoryId(Long id);
}
